package com.holic.spring.custom.exception;

import graphql.ErrorType;
import graphql.GraphQLError;
import graphql.language.SourceLocation;

import java.util.Collections;
import java.util.List;

/**
 * @ClassName CustomGraphQLError
 * @Description
 * @Author Neil
 * @Date 2024/11/14 17:43
 * @Version V1.0
 **/
public class CustomGraphQLError implements GraphQLError {

    private final String message;
    private final String errorCode;

    public CustomGraphQLError(String message, String errorCode) {
        this.message = message;
        this.errorCode = errorCode;
    }

    @Override
    public String getMessage() {
        return message;
    }

    @Override
    public List<SourceLocation> getLocations() {
        return Collections.emptyList();
    }

    @Override
    public ErrorType getErrorType() {
        return ErrorType.DataFetchingException;
    }

    public String getErrorCode() {
        return errorCode;
    }

}
